package com.dsit.sq;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.View.OnClickListener;
import android.widget.ImageView;

/**
 * Created by dsit_dev04 on 2016/10/8.
 */
public class CarDataActivity extends BaseActivity implements OnClickListener,OnTouchListener {
    private ImageView returnImageView;
    private ImageView dongliImageView;
    private ImageView fuelBatteryImageView;
    private ImageView qingStatusImageView;
    private ImageView otherImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cardata);
        StatusBarBackChange.setStatusBarBack(this);
        returnImageView = (ImageView)findViewById(R.id.car_data_return_button);
        returnImageView.setOnClickListener(this);
        dongliImageView = (ImageView)findViewById(R.id.dongli_image);
        dongliImageView.setOnClickListener(this);
        dongliImageView.setOnTouchListener(this);
        fuelBatteryImageView = (ImageView)findViewById(R.id.fuel_battery_image);
        fuelBatteryImageView.setOnClickListener(this);
        fuelBatteryImageView.setOnTouchListener(this);
        qingStatusImageView = (ImageView)findViewById(R.id.qing_status_image);
        qingStatusImageView.setOnClickListener(this);
        qingStatusImageView.setOnTouchListener(this);
        otherImageView = (ImageView)findViewById(R.id.other_image);
        otherImageView.setOnClickListener(this);
        otherImageView.setOnTouchListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.car_data_return_button:
                finish();
                break;
            case R.id.dongli_image:
                Intent intent = new Intent(this,DetailCarDataActivity.class);
                startActivity(intent);
                break;
            case R.id.fuel_battery_image:
                Intent intent1 = new Intent(this,FuelBatteryActivity.class);
                startActivity(intent1);
                break;
            case R.id.qing_status_image:
                Intent intent2 = new Intent(this,QingActivity.class);
                startActivity(intent2);
                break;
            case R.id.other_image:
                Intent intent3 = new Intent(this,OtherActivity.class);
                startActivity(intent3);
                break;
            default:
                break;
        }
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        switch (v.getId()){
            case R.id.dongli_image:
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    dongliImageView.setBackgroundResource(R.mipmap.btn_dongli_press);
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    dongliImageView.setBackgroundResource(R.mipmap.btn_dongli_nor);
                }
                break;
            case R.id.fuel_battery_image:
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    fuelBatteryImageView.setBackgroundResource(R.mipmap.btn_ranliao_press);
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    fuelBatteryImageView.setBackgroundResource(R.mipmap.btn_ranliao_nor);
                }
                break;
            case R.id.qing_status_image:
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    qingStatusImageView.setBackgroundResource(R.mipmap.btn_h_press);
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    qingStatusImageView.setBackgroundResource(R.mipmap.btn_h_nor);
                }
                break;
            case R.id.other_image:
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    otherImageView.setBackgroundResource(R.mipmap.btn_ohter_press);
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    otherImageView.setBackgroundResource(R.mipmap.btn_ohter_nor);
                }
                break;
            default:
                break;
        }
        return false;
    }
}
